﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head th:include="include :: head('我的桌面')"></head>
<body>
<div class="yadmin-body animated fadeIn">
    <h1>欢迎使用管理后台！</h1>
    <div class="layui-text">
        <p>登录次数：[[${loginCount}]] </p>
        <p>上次登录IP：[[${ip}]] 上次登录时间：[[${lastDate}]]</p>
    </div>
    <thead>
        <tr>
            <th colspan="2" scope="col">服务器信息</th>
        </tr>
    </thead>
    <table class="layui-table">
        <tr>
            <th width="30%">服务器计算机名</th>
            <td><span id="lbServerName">[[${os.computerName}]]</span></td>
        </tr>
        <tr>
            <td>服务器MAC</td>
            <td>[[${os.mac}]]</td>
        </tr>
        <tr>
            <td>服务器IP地址</td>
            <td>[[${os.ip}]]</td>
        </tr>
        <tr>
            <td>服务器端口</td>
            <td>[[${port}]]</td>
        </tr>
        <tr>
            <td>项目所在文件夹</td>
            <td>[[${os.itemPath}]]</td>
        </tr>
        <tr>
            <td>服务器操作系统</td>
            <td>[[${os.osname}]]</td>
        </tr>
        <tr>
            <td>用户工作目录</td>
            <td>[[${os.userdir}]]</td>
        </tr>
        <tr>
            <td>当前系统用户名</td>
            <td>[[${os.sysUserName}]]</td>
        </tr>
        <tr>
            <td>服务器当前时间</td>
            <td id="clock">[[${os.sysTime}]]</td>
        </tr>
        <tr>
            <td>服务器上次启动到现在已运行</td>
            <td id="runTime">[[${startDate}]]</td>
        </tr>
        <tr>
            <td>JAVA版本</td>
            <td>[[${os.java}]]</td>
        </tr>
        <tr>
            <td>虚拟机内存总量</td>
            <td>[[${os.vmRamTotal}]]</td>
        </tr>
        <tr>
            <td>当前程序占用内存</td>
            <td>[[${os.useRamTotal}]]</td>
        </tr>
    </table>
</div>
</body>
<script th:inline="javascript">
    function intervalTime() {
        var runTime = document.getElementById("runTime").innerHTML;
        var date = new Date(runTime);
        var lag = new Date().getTime() - date.getTime();  //时间差的毫秒数
        //计算出相差天数
        var days = Math.floor(lag / (24 * 3600 * 1000));
        //计算出小时数
        var leave1 = lag % (24 * 3600 * 1000);    //计算天数后剩余的毫秒数
        var hours = Math.floor(leave1 / (3600 * 1000));
        var ret = days + "天 " + hours + "小时 ";
        document.getElementById("runTime").innerHTML = ret;
    }

    function clock() {
        var time = new Date().Format("yyyy-MM-dd HH:mm:ss");
        document.getElementById("clock").innerHTML = time;
    }

    setInterval(clock, 1000);
    intervalTime();
</script>
</html>